package cn.itsource.org.controller;

import cn.itsource.basic.utils.AjaxResult;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.query.EmployeeQuery;
import cn.itsource.org.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author CTL
 * @Description
 * @date Created in 2023-05-16 14:37
 */

@RestController
@RequestMapping("/empl")
@Api(value = "EmployeeController",tags = {"员工管理"})
public class EmployeeController {
    @Autowired
    private IEmployeeService service;

    //查询所有
    @ApiOperation("获取所有数据")
    @GetMapping("/getAll")
    public AjaxResult getAll(){
        return AjaxResult.createSuccess(service.getAll());
    }

    //分页查询
    @ApiOperation("获取所有数据")
    @PostMapping("/getPageList")
    public AjaxResult getPageList(@RequestBody EmployeeQuery query){
        return AjaxResult.createSuccess(service.getPageList(query));
    }

    //添加修改
    @ApiOperation("添加修改")
    @PostMapping("/addOrUpdate")
    public AjaxResult addOrUpdate(@RequestBody Employee employee){
            service.addOrUpdate(employee);
            return AjaxResult.createSuccess();

    }

    //删除
    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public AjaxResult Delete(@PathVariable Long id){
            service.delete(id);
            return AjaxResult.createSuccess();

    }
    //项目经理
    @GetMapping("/getAllDepaManger")
    public AjaxResult getAllDepaManger(){
        return AjaxResult.createSuccess(service.getAllDepaManger());
    }

}
